package com.xuef.repository;

import com.xuef.entity.EsBlog;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
import org.springframework.stereotype.Component;

/**
 * Created by moveb on 2018/5/9.
 */
@Component
public interface EsBlogRepository extends ElasticsearchRepository<EsBlog, String> {

    /**
     * 模糊查询(去重)
     * 根据title summary content tags 是否包含指定内容来搜索
     * @param title
     * @param Summary
     * @param content
     * @param tags
     * @param pageable
     * @return
     */
    Page<EsBlog> findDistinctEsBlogByTitleContainingOrSummaryContainingOrContentContainingOrTagsContaining(String title,
                                                                                                           String Summary, String content,
                                                                                                           String tags, Pageable pageable);

    EsBlog findByBlogId(Integer blogId);

    Page<EsBlog> findDistinctEsBlogByUsernameContainingOrTitleContainingOrSummaryContainingOrContentContainingOrTagsContaining(String username, String title,
                                                                                                                               String Summary, String content,
                                                                                                                               String tags, Pageable pageable);
}
